﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Electure.DAL;

namespace Electure
{
    public partial class ShowVideoLecture : System.Web.UI.Page
    {
        public string FilePath = "";
        int? Id
        {
            get
            {
                int? res = new int?();
                int id;
                if (int.TryParse(Request.QueryString["id"], out id))
                    res = id;
                return res;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Id.HasValue)
                Response.Redirect("VideoLectures");

            using (var rep = RepositoryFactory.GetPublicationRepository())
            {
                var instance = rep.GetById(Id.Value);

                lbName.InnerText = instance.Name;
                lbCreateDate.InnerText = instance.CreateDate.ToShortDateString();
                newsDescription.InnerText = instance.Description;
                if (instance.Image != null)
                    imagePreview.ImageUrl = ResolveClientUrl(instance.Image.GetFullPath());
                //TODO: add repeater of videos
                repVideos.DataSource = instance.VideoFiles;
                repVideos.DataBind();
                //FilePath = instance.VideoFiles[1].GetFullPath();
            }
        }

        protected void repVideos_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {

        }
    }
}